<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <button class="btn">清除计时器</button>
    <button class="btn2">清除延时器</button>

</body>
<script>
    var obtn=document.querySelector(".btn")
    // 计时器
    var t1=setInterval(function(){
        console.log("张新同")
    },1000)

    // 清除计时器
    obtn.onclick=function(){
        // 清除计时器的唯一标准
        clearInterval(t1)
    }

    // 延时器
    var t2=setTimeout(function(){
        console.log("最帅")
    },3000)
    var obtn2=document.querySelector(".btn2")
    obtn2.onclick=function(){
        clearTimeout(t2)
    }
</script>
</html>